package com.lei.factory;

import com.lei.util.ClassLoaderUtils;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author: leiGer
 * @Date: 2022/01/15
 * @Time: 16:54
 */
public class JDKInvocationHandler implements InvocationHandler {
    private ICacheAdapt iCacheAdapt;

    public JDKInvocationHandler(ICacheAdapt iCacheAdapt) {
        this.iCacheAdapt = iCacheAdapt;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        return ICacheAdapt.class.getMethod(method.getName(), ClassLoaderUtils.getClazzByArgs(args)).invoke(iCacheAdapt,args);
    }
}
